<?php 
class MD_Content
{
	public static function getContentById($id)
	{
		$content = TN_Db::getInstance()->fetchAll("SELECT * FROM content where id = '$id' ");
    	return $content[0];
	} 
	
	public static function getContentsByCategory($c)
	{
		return TN_Db::getInstance()->fetchAll("SELECT * FROM content  where id_category = '$c' ORDER BY id");
	}
	
	public static function getEnabledContentsByCategory($c)
	{
		return TN_Db::getInstance()->fetchAll("SELECT * FROM content  where id_category = '$c' and enabled = 1 ORDER BY title");
	}
	
	public static function add( $title, $content, $enabled, $category )
	{
		TN_Db::getInstance()->insert('content', array('title'=> $title, 'content' => $content,'enabled' => $enabled , 'id_category' => $category));
	}
	
	public static function update( $id , $title, $content, $enabled, $category )
	{
		TN_Db::getInstance()->update('content', array('title'=> $title, 'content' => $content,'enabled' => $enabled,'id_category' => $category), "id = '$id' ");
	}
	
	public static function delete ($id )
	{
		TN_Db::getInstance()->delete('content', "id = '$id' ");
	}
}
?>